#include "CommonRead.h"
#include <fstream>
#include <iostream>
#include <stdio.h>

CommonRead::CommonRead(void)
{
    
}


CommonRead::~CommonRead(void)
{
}

void CommonRead::CommonReadFstream(std::string &fileName)
{
    char readBuff[bufferSize];
	std::streamsize readSize=bufferSize;
    std::ifstream ifs;
	ifs.open(fileName.c_str(), std::ios::in|std::ios::binary);
	if (ifs.is_open() == true)
	{
		while ( (ifs.good())  && (readSize == bufferSize) )
		{
			readSize = ifs.readsome(readBuff,bufferSize);
			std::cout << readBuff << std::endl;
		}
		ifs.close();
	}
}

void CommonRead::CommonReadCFile(std::string &fileName)
{
    char readBuff[bufferSize];
   
    FILE* fp = NULL;
    fp = fopen(fileName.c_str(),"rb");
    while(!feof(fp))
    {
        fread(readBuff,1,bufferSize,fp);
        std::cout << readBuff << std::endl;
    }
    fclose(fp);
}
